package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;

import logic.Facade;
import logic.ToGuiFacade;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class pnlRemoveMovie extends javax.swing.JPanel {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private JComboBox moviesCmb;
	private JLabel jLabel1;
	private JButton submitBtn;
	private JLabel headerLbl;
	private JLabel alertLabel;
	private JButton cancelBtn;
	//private String _user;
	private final pnlRemoveMovie _this;

	public pnlRemoveMovie(String user) {
		super();
//		_user = user;
		_this = this;
		initGUI();
	}

	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(400, 217));
			this.setLayout(null);
			this.setBackground(new java.awt.Color(255,128,0));
			{
				ComboBoxModel moviesCmbModel =
					new DefaultComboBoxModel(
							Facade.getInstance().getMovies());
				moviesCmb = new JComboBox();
				this.add(moviesCmb);
				moviesCmb.setModel(moviesCmbModel);
				moviesCmb.setBounds(23, 98, 178, 21);
			}
			{
				jLabel1 = new JLabel();
				this.add(jLabel1);
				jLabel1.setText("Select movie to remove:");
				jLabel1.setBounds(23, 72, 161, 14);
			}
			{
				submitBtn = new JButton();
				this.add(submitBtn);
				submitBtn.setText("Submit");
				submitBtn.setBounds(208, 165, 92, 21);
				submitBtn.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){
						if (moviesCmb.getSelectedItem()!=null){
							ToGuiFacade.getInstance().setRemoveMovieScreen(_this);
							Facade.getInstance().deleteMovie((String)moviesCmb.getSelectedItem());
							ComboBoxModel moviesCmbModel =
								new DefaultComboBoxModel(
										Facade.getInstance().getMovies());
							moviesCmb.setModel(moviesCmbModel);

						}
					}
				});
			}
			{
				cancelBtn = new JButton();
				this.add(cancelBtn);
				cancelBtn.setText("back");
				cancelBtn.setBounds(86, 165, 87, 21);
				cancelBtn.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){
						ToGuiFacade.getInstance().back();
						//ToGuiFacade.getInstance().showUserScreen(_user, true);
					}
				});
			}
			{
				headerLbl = new JLabel();
				this.add(headerLbl);
				headerLbl.setText("Movie Removal");
				headerLbl.setBounds(23, 22, 150, 26);
				headerLbl.setFont(new java.awt.Font("Arial",1,14));
			}
			{
				alertLabel = new JLabel();
				this.add(alertLabel);
				alertLabel.setBounds(173, 48, 198, 17);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void setAlertLabel(String msg){
		alertLabel.setText(msg);
	}

}
